import 'package:dartx/dartx.dart';
import 'package:gluz/app/common/extension/string_extension.dart';
import 'package:gluz/generated/json/base/json_field.dart';
import 'package:gluz/generated/json/shop_list_entity.g.dart';
import 'dart:convert';
export 'package:gluz/generated/json/shop_list_entity.g.dart';

@JsonSerializable()
class ShopListEntity {
	String id = '';
	int skuId = 0;
	int spuId = 0;
	dynamic userId;
	String skuName = '';
	String spuName = '';
	int classId = 0;
	String className = '';
	String allClassName = '';
	int brandId = 0;
	String brandName = '';
	String suppName = '';
	String suppCode = '';
	int venderId = 0;
	int salesPrice = 0;
	String salesCurrency = '';
	int stockNum = 0;
	int stockStateType = 0;
	String stockStateDesc = '';
	int isAreaRestrict = 0;
	int thirdSkuSource = 0;
	int skuState = 0;
	int skuType = 0;
	int selfSellType = 0;
	int saleModel = 0;
	String mainPicUrl = '';
	int lowestBuy = 0;
	int deliveryTime = 0;
	int logisticsType = 0;
	int logisticsState = 0;
	int collectionsTotal = 0;
	String createdTime = '';
	String updatedTime = '';
	String currencyUnit = '';
	String minOrderQuantity = '';
	String wholesalePrice = '';
	String totalStock = '';
	String shippingAddress = '';
	String productDescription = '';
	int isConsignment = 0;
	dynamic detail;
	String images = '';
	int pageView = 0;
	String userName = '';
	String userImg = '';
	String userCountry = '';
	String memberLevel = '';
	int isSample = 0; // 是否是样品

	ShopListEntity();

	factory ShopListEntity.fromJson(Map<String, dynamic> json) => $ShopListEntityFromJson(json);

	Map<String, dynamic> toJson() => $ShopListEntityToJson(this);

	String getMainPicUrl() {
		if (thirdSkuSource==1) { // 京东
			return mainPicUrl.jdImgFullUrl();
		}
		return mainPicUrl;
	}

	String getMemberLevelUrl() {
		if (memberLevel.isEmpty) {
			memberLevel = '0';
		}
		if (memberLevel.toInt() > 3) {
			memberLevel = '3';
		}
		return 'https://gluz-oss.oss-cn-beijing.aliyuncs.com/shopstatic/work/member$memberLevel.png';
	}

	@override
	String toString() {
		return jsonEncode(this);
	}
}